home *** CD-ROM | disk | FTP | other *** search
/ Netscape Plug-Ins Developer's Kit / Netscape_Plug-Ins_Developers_Kit.iso / CGIPERL / MACPERL / MSRCE418.HQX / Perl Source ƒ / Perl / perl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-26  |  23.7 KB  |  1,135 lines

  1. /* $RCSfile: perl.h,v $$Revision: 4.0.1.7 $$Date: 1993/02/05 19:40:30 $
  2.  *
  3.  *    Copyright (c) 1991, Larry Wall
  4.  *
  5.  *    You may distribute under the terms of the Perl Artistic License,
  6.  *    as specified in the README file.
  7.  *
  8.  * $Log:    perl.h,v $
  9.  * Revision 4.0.1.6  1992/06/08  14:55:10  lwall
  10.  * patch20: added Atari ST portability
  11.  * patch20: bcopy() and memcpy() now tested for overlap safety
  12.  * patch20: Perl now distinguishes overlapped copies from non-overlapped
  13.  * patch20: removed implicit int declarations on functions
  14.  * 
  15.  * Revision 4.0.1.5  91/11/11  16:41:07  lwall
  16.  * patch19: uts wrongly defines S_ISDIR() et al
  17.  * patch19: too many preprocessors can't expand a macro right in #if
  18.  * patch19: added little-endian pack/unpack options
  19.  * 
  20.  * Revision 4.0.1.4  91/11/05  18:06:10  lwall
  21.  * patch11: various portability fixes
  22.  * patch11: added support for dbz
  23.  * patch11: added some support for 64-bit integers
  24.  * patch11: hex() didn't understand leading 0x
  25.  * 
  26.  * Revision 4.0.1.3  91/06/10  01:25:10  lwall
  27.  * patch10: certain pattern optimizations were botched
  28.  * 
  29.  * Revision 4.0.1.2  91/06/07  11:28:33  lwall
  30.  * patch4: new copyright notice
  31.  * patch4: made some allowances for "semi-standard" C
  32.  * patch4: many, many itty-bitty portability fixes
  33.  * 
  34.  * Revision 4.0.1.1  91/04/11  17:49:51  lwall
  35.  * patch1: hopefully straightened out some of the Xenix mess
  36.  * 
  37.  * Revision 4.0  91/03/20  01:37:56  lwall
  38.  * 4.0 baseline.
  39.  * 
  40.  */
  41.  
  42. #define VOIDWANT 1
  43. #include "config.h"
  44.  
  45. #ifdef MYMALLOC
  46. #   ifdef HIDEMYMALLOC
  47. #    define malloc Mymalloc
  48. #    define realloc Myremalloc
  49. #    define free Myfree
  50. #   endif
  51. #   define safemalloc malloc
  52. #   define saferealloc realloc
  53. #   define safefree free
  54. #endif
  55.  
  56. /* work around some libPW problems */
  57. #define fatal Myfatal
  58. #ifdef DOINIT
  59. char Error[1];
  60. #endif
  61.  
  62. /* [Macintosh] The Mac is almost MS-DOS compatible:
  63.    no userids, no groupids, no forking
  64. */
  65.  
  66. /* define this once if either system, instead of cluttering up the src */
  67.  
  68. #ifdef MSDOS
  69. #define MSMAC    1
  70. #define DOSISH     1
  71. #define NIXUNIX    1
  72. #else
  73. #ifdef macintosh
  74. #define MSMAC    1
  75. #undef  DOSISH
  76. #define NIXUNIX    1
  77. #else
  78. #ifdef atarist
  79. #undef    MSMAC
  80. #define DOSISH    1
  81. #define NIXUNIX    1
  82. #else
  83. #undef MSMAC
  84. #undef DOSISH
  85. #undef NIXUNIX
  86. #endif
  87. #endif
  88. #endif
  89.  
  90. #ifdef NIXUNIX
  91. /* This stuff now in the MS-DOS config.h file. */
  92. #else /* !MSMAC */
  93.  
  94. /*
  95.  * The following symbols are defined if your operating system supports
  96.  * functions by that name.  All Unixes I know of support them, thus they
  97.  * are not checked by the configuration script, but are directly defined
  98.  * here.
  99.  */
  100. #define HAS_ALARM
  101. #define HAS_CHOWN
  102. #define HAS_CHROOT
  103. #define HAS_FORK
  104. #define HAS_GETLOGIN
  105. #define HAS_GETPPID
  106. #define HAS_KILL
  107. #define HAS_LINK
  108. #define HAS_PIPE
  109. #define HAS_WAIT
  110. #define HAS_UMASK
  111. /*
  112.  * The following symbols are defined if your operating system supports
  113.  * password and group functions in general.  All Unix systems do.
  114.  */
  115. #define HAS_GROUP
  116. #define HAS_PASSWD
  117.  
  118. #endif /* !NIXUNIX */
  119.  
  120. #if defined(__STDC__) || defined(_AIX) || defined(__stdc__)
  121. # define STANDARD_C 1
  122. #endif
  123.  
  124. /* [Macintosh] MPW C 3.1 seems to be not quite ANSI-compatible */
  125.  
  126. #ifdef STANDARD_C
  127. #define    STDMAC
  128. #else
  129. #ifdef macintosh
  130. #define    STDMAC
  131. #else
  132. #undef STDMAC
  133. #endif
  134. #endif
  135.  
  136. #if defined(HASVOLATILE) || defined(STANDARD_C)
  137. #define VOLATILE volatile
  138. #else
  139. #define VOLATILE
  140. #endif
  141.  
  142. #ifdef IAMSUID
  143. #   ifndef TAINT
  144. #    define TAINT
  145. #   endif
  146. #endif
  147.  
  148. #ifndef HAS_VFORK
  149. #   define vfork fork
  150. #endif
  151.  
  152. #ifdef HAS_GETPGRP2
  153. #   ifndef HAS_GETPGRP
  154. #    define HAS_GETPGRP
  155. #   endif
  156. #   define getpgrp getpgrp2
  157. #endif
  158.  
  159. #ifdef HAS_SETPGRP2
  160. #   ifndef HAS_SETPGRP
  161. #    define HAS_SETPGRP
  162. #   endif
  163. #   define setpgrp setpgrp2
  164. #endif
  165.  
  166. #include <stdio.h>
  167. #include <ctype.h>
  168. #include <setjmp.h>
  169. #ifndef MSMAC
  170. #ifdef PARAM_NEEDS_TYPES
  171. #include <sys/types.h>
  172. #endif
  173. #include <sys/param.h>
  174. #endif
  175. #ifdef STDMAC
  176. /* Use all the "standard" definitions */
  177. #include <stdlib.h>
  178. #include <string.h>
  179. #define MEM_SIZE size_t
  180. #else
  181. typedef unsigned int MEM_SIZE;
  182. #endif /* STDMAC */
  183.  
  184. #if defined(HAS_MEMCMP) && defined(mips) && defined(ultrix)
  185. #undef HAS_MEMCMP
  186. #endif
  187.  
  188. #ifdef HAS_MEMCPY
  189. #  ifndef STDMAC
  190. #    ifndef memcpy
  191.       extern char * memcpy();
  192. #    endif /* ndef memcpy */
  193. #  endif /* ndef STDMAC */
  194. #else
  195. #  ifndef memcpy
  196. #    ifdef HAS_BCOPY
  197. #     define memcpy(d,s,l) bcopy(s,d,l)
  198. #    else
  199. #     define memcpy(d,s,l) my_bcopy(s,d,l)
  200. #    endif
  201. #  endif
  202. #endif /* HAS_MEMCPY */
  203.   
  204. #ifdef HAS_MEMSET
  205. #  ifndef STDMAC
  206. #    ifndef memset
  207.     extern char *memset();
  208. #    endif
  209. #  endif
  210. #  define memzero(d,l) memset(d,0,l)
  211. #else
  212. #   ifndef memzero
  213. #    ifdef HAS_BZERO
  214. #        define memzero(d,l) bzero(d,l)
  215. #    else
  216. #        define memzero(d,l) my_bzero(d,l)
  217. #    endif
  218. #   endif
  219. #endif /* HAS_MEMSET */
  220.  
  221. #ifdef HAS_MEMCMP
  222. #  ifndef STDMAC
  223. #    ifndef memcmp
  224.     extern int memcmp();
  225. #    endif
  226. #  endif
  227. #else
  228. #   ifndef memcmp
  229. #    define memcmp(s1,s2,l) my_memcmp(s1,s2,l)
  230. #   endif
  231. #endif /* HAS_MEMCMP */
  232.  
  233. /* we prefer bcmp slightly for comparisons that don't care about ordering */
  234. #ifndef HAS_BCMP
  235. #   ifndef bcmp
  236. #    define bcmp(s1,s2,l) memcmp(s1,s2,l)
  237. #   endif
  238. #endif /* HAS_BCMP */
  239.  
  240. #ifndef HAS_MEMMOVE
  241. #if defined(HAS_BCOPY) && defined(SAFE_BCOPY)
  242. #define memmove(d,s,l) bcopy(s,d,l)
  243. #else
  244. #if defined(HAS_MEMCPY) && defined(SAFE_MEMCPY)
  245. #define memmove(d,s,l) memcpy(d,s,l)
  246. #else
  247. #define memmove(d,s,l) my_bcopy(s,d,l)
  248. #endif
  249. #endif
  250. #endif
  251.  
  252.  
  253. #ifndef _TYPES_        /* If types.h defines this it's easy. */
  254. #ifndef major        /* Does everyone's types.h define this? */
  255. #include <sys/types.h>
  256. #endif
  257. #endif
  258.  
  259. #ifdef I_NETINET_IN
  260. #include <netinet/in.h>
  261. #endif
  262.  
  263. #include <sys/stat.h>
  264. #if defined(uts) || defined(UTekV)
  265. #undef S_ISDIR
  266. #undef S_ISCHR
  267. #undef S_ISBLK
  268. #undef S_ISREG
  269. #undef S_ISFIFO
  270. #undef S_ISLNK
  271. #define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR)
  272. #define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR)
  273. #define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK)
  274. #define S_ISREG(P) (((P)&S_IFMT)==S_IFREG)
  275. #define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO)
  276. #ifdef S_IFLNK
  277. #define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK)
  278. #endif
  279. #endif
  280.  
  281. #ifdef I_TIME
  282. #   include <time.h>
  283. #endif
  284.  
  285. #ifdef I_SYS_TIME
  286. #   ifdef SYSTIMEKERNEL
  287. #    define KERNEL
  288. #   endif
  289. #   include <sys/time.h>
  290. #   ifdef SYSTIMEKERNEL
  291. #    undef KERNEL
  292. #   endif
  293. #endif
  294.  
  295. #ifndef MSMAC
  296. #include <sys/times.h>
  297. #endif
  298.  
  299. #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
  300. #undef HAS_STRERROR
  301. #endif
  302.  
  303. #include <errno.h>
  304. #ifndef MSDOS
  305. #ifndef errno
  306. extern int errno;     /* ANSI allows errno to be an lvalue expr */
  307. #endif
  308. #endif
  309.  
  310. #ifndef strerror
  311. #ifdef HAS_STRERROR
  312. char *strerror();
  313. #else
  314. extern int sys_nerr;
  315. extern char *sys_errlist[];
  316. #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
  317. #endif
  318. #endif
  319.  
  320. #ifdef I_SYSIOCTL
  321. #ifndef _IOCTL_
  322. #include <sys/ioctl.h>
  323. #endif
  324. #endif
  325.  
  326. #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
  327. #ifdef HAS_SOCKETPAIR
  328. #undef HAS_SOCKETPAIR
  329. #endif
  330. #ifdef HAS_NDBM
  331. #undef HAS_NDBM
  332. #endif
  333. #endif
  334.  
  335. #ifdef WANT_DBZ
  336. #include <dbz.h>
  337. #define SOME_DBM
  338. #define dbm_fetch(db,dkey) fetch(dkey)
  339. #define dbm_delete(db,dkey) fatal("dbz doesn't implement delete")
  340. #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  341. #define dbm_close(db) dbmclose()
  342. #define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  343. #define nextkey() (fatal("dbz doesn't implement traversal"),fetch())
  344. #define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  345. #ifdef HAS_NDBM
  346. #undef HAS_NDBM
  347. #endif
  348. #ifndef HAS_ODBM
  349. #define HAS_ODBM
  350. #endif
  351. #else
  352. #ifdef HAS_GDBM
  353. #ifdef I_GDBM
  354. #include <gdbm.h>
  355. #endif
  356. #define SOME_DBM
  357. #ifdef HAS_NDBM
  358. #undef HAS_NDBM
  359. #endif
  360. #ifdef HAS_ODBM
  361. #undef HAS_ODBM
  362. #endif
  363. #else
  364. #ifdef HAS_NDBM
  365. #include <ndbm.h>
  366. #define SOME_DBM
  367. #ifdef HAS_ODBM
  368. #undef HAS_ODBM
  369. #endif
  370. #else
  371. #ifdef HAS_ODBM
  372. #ifdef NULL
  373. #undef NULL        /* suppress redefinition message */
  374. #endif
  375. #include <dbm.h>
  376. #ifdef NULL
  377. #undef NULL
  378. #endif
  379. #define NULL 0        /* silly thing is, we don't even use this */
  380. #define SOME_DBM
  381. #define dbm_fetch(db,dkey) fetch(dkey)
  382. #define dbm_delete(db,dkey) delete(dkey)
  383. #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  384. #define dbm_close(db) dbmclose()
  385. #define dbm_firstkey(db) firstkey()
  386. #endif /* HAS_ODBM */
  387. #endif /* HAS_NDBM */
  388. #endif /* HAS_GDBM */
  389. #endif /* WANT_DBZ */
  390. #ifdef SOME_DBM
  391. EXT char *dbmkey;
  392. EXT int dbmlen;
  393. #endif
  394.  
  395. #if INTSIZE == 2
  396. #define htoni htons
  397. #define ntohi ntohs
  398. #else
  399. #define htoni htonl
  400. #define ntohi ntohl
  401. #endif
  402.  
  403. #if defined(I_DIRENT)
  404. #   include <dirent.h>
  405. #   define DIRENT dirent
  406. #else
  407. #   ifdef I_SYS_NDIR
  408. #    include <sys/ndir.h>
  409. #    define DIRENT direct
  410. #   else
  411. #    ifdef I_SYS_DIR
  412. #        ifdef hp9000s500
  413. #        include <ndir.h>    /* may be wrong in the future */
  414. #        else
  415. #        include <sys/dir.h>
  416. #        endif
  417. #        define DIRENT direct
  418. #    endif
  419. #   endif
  420. #endif
  421.  
  422. #ifdef macintosh
  423. #include <Memory.h>
  424. #include "SubLaunch.h"
  425. #include <TFileSpec.h>
  426. #include <CursorCtl.h>
  427.  
  428. void InitToolbox();
  429. char * MPWPosIndication(char * buf, char * file, long line);
  430. char * MPWFileName(char * file);
  431. void SpinMacCursor();
  432.  
  433. EXT int extract_offset INIT(0);
  434. EXT FILE * perldbg;
  435.  
  436. #include "MacPerl.h"
  437. #endif
  438.  
  439. #ifdef FPUTS_BOTCH
  440. /* work around botch in SunOS 4.0.1 and 4.0.2 */
  441. #   ifndef fputs
  442. #    define fputs(str,fp) fprintf(fp,"%s",str)
  443. #   endif
  444. #endif
  445.  
  446. /*
  447.  * The following gobbledygook brought to you on behalf of __STDC__.
  448.  * (I could just use #ifndef __STDC__, but this is more bulletproof
  449.  * in the face of half-implementations.)
  450.  */
  451.  
  452. #ifndef S_IFMT
  453. #   ifdef _S_IFMT
  454. #    define S_IFMT _S_IFMT
  455. #   else
  456. #    define S_IFMT 0170000
  457. #   endif
  458. #endif
  459.  
  460. #ifndef S_ISDIR
  461. #   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
  462. #endif
  463.  
  464. #ifndef S_ISCHR
  465. #   define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
  466. #endif
  467.  
  468. #ifndef S_ISBLK
  469. #   ifdef S_IFBLK
  470. #    define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
  471. #   else
  472. #    define S_ISBLK(m) (0)
  473. #   endif
  474. #endif
  475.  
  476. #ifndef S_ISREG
  477. #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
  478. #endif
  479.  
  480. #ifndef S_ISFIFO
  481. #   ifdef S_IFIFO
  482. #    define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
  483. #   else
  484. #    define S_ISFIFO(m) (0)
  485. #   endif
  486. #endif
  487.  
  488. #ifndef S_ISLNK
  489. #   ifdef _S_ISLNK
  490. #    define S_ISLNK(m) _S_ISLNK(m)
  491. #   else
  492. #    ifdef _S_IFLNK
  493. #        define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
  494. #    else
  495. #        ifdef S_IFLNK
  496. #        define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
  497. #        else
  498. #        define S_ISLNK(m) (0)
  499. #        endif
  500. #    endif
  501. #   endif
  502. #endif
  503.  
  504. #ifndef S_ISSOCK
  505. #   ifdef _S_ISSOCK
  506. #    define S_ISSOCK(m) _S_ISSOCK(m)
  507. #   else
  508. #    ifdef _S_IFSOCK
  509. #        define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
  510. #    else
  511. #        ifdef S_IFSOCK
  512. #        define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
  513. #        else
  514. #        define S_ISSOCK(m) (0)
  515. #        endif
  516. #    endif
  517. #   endif
  518. #endif
  519.  
  520. #ifndef S_IRUSR
  521. #   ifdef S_IREAD
  522. #    define S_IRUSR S_IREAD
  523. #    define S_IWUSR S_IWRITE
  524. #    define S_IXUSR S_IEXEC
  525. #   else
  526. #    define S_IRUSR 0400
  527. #    define S_IWUSR 0200
  528. #    define S_IXUSR 0100
  529. #   endif
  530. #   define S_IRGRP (S_IRUSR>>3)
  531. #   define S_IWGRP (S_IWUSR>>3)
  532. #   define S_IXGRP (S_IXUSR>>3)
  533. #   define S_IROTH (S_IRUSR>>6)
  534. #   define S_IWOTH (S_IWUSR>>6)
  535. #   define S_IXOTH (S_IXUSR>>6)
  536. #endif
  537.  
  538. #ifndef S_ISUID
  539. #   define S_ISUID 04000
  540. #endif
  541.  
  542. #ifndef S_ISGID
  543. #   define S_ISGID 02000
  544. #endif
  545.  
  546. #ifdef f_next
  547. #undef f_next
  548. #endif
  549.  
  550. #if defined(cray) || defined(gould) || defined(i860)
  551. #   define SLOPPYDIVIDE
  552. #endif
  553.  
  554. #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
  555. #   define QUAD
  556. #endif
  557.  
  558. #ifdef QUAD
  559. #   ifdef cray
  560. #    define quad int
  561. #   else
  562. #    if defined(convex) || defined (uts)
  563. #        define quad long long
  564. #    else
  565. #        define quad long
  566. #    endif
  567. #   endif
  568. #endif
  569.  
  570. typedef MEM_SIZE STRLEN;
  571.  
  572. typedef struct arg ARG;
  573. typedef struct cmd CMD;
  574. typedef struct formcmd FCMD;
  575. typedef struct scanpat SPAT;
  576. typedef struct stio STIO;
  577. typedef struct sub SUBR;
  578. typedef struct string STR;
  579. typedef struct atbl ARRAY;
  580. typedef struct htbl HASH;
  581. typedef struct regexp REGEXP;
  582. typedef struct stabptrs STBP;
  583. typedef struct stab STAB;
  584. typedef struct callsave CSV;
  585.  
  586. #include "handy.h"
  587. #include "regexp.h"
  588. #include "str.h"
  589. #include "util.h"
  590. #include "form.h"
  591. #include "stab.h"
  592. #include "spat.h"
  593. #include "arg.h"
  594. #include "cmd.h"
  595. #include "array.h"
  596. #include "hash.h"
  597.  
  598. #if defined(iAPX286) || defined(M_I286) || defined(I80286)
  599. #   define I286
  600. #endif
  601.  
  602. #ifndef    STDMAC
  603. #ifdef CHARSPRINTF
  604.     char *sprintf();
  605. #else
  606.     int sprintf();
  607. #endif
  608. #endif
  609.  
  610. EXT char *Yes INIT("1");
  611. EXT char *No INIT("");
  612.  
  613. /* "gimme" values */
  614.  
  615. /* Note: cmd.c assumes that it can use && to produce one of these values! */
  616. #define G_SCALAR 0
  617. #define G_ARRAY 1
  618.  
  619. #ifdef CRIPPLED_CC
  620. int str_true();
  621. #else /* !CRIPPLED_CC */
  622. #define str_true(str) (Str = (str), \
  623.     (Str->str_pok ? \
  624.         ((*Str->str_ptr > '0' || \
  625.           Str->str_cur > 1 || \
  626.           (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
  627.     : \
  628.         (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
  629. #endif /* CRIPPLED_CC */
  630.  
  631. #ifdef DEBUGGING
  632. #define str_peek(str) (Str = (str), \
  633.     (Str->str_pok ? \
  634.         Str->str_ptr : \
  635.         (Str->str_nok ? \
  636.         (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
  637.             (char*)tokenbuf) : \
  638.         "" )))
  639. #endif
  640.  
  641. #ifdef CRIPPLED_CC
  642. char *str_get();
  643. #else
  644. #ifdef TAINT
  645. #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
  646.     (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  647. #else
  648. #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  649. #endif /* TAINT */
  650. #endif /* CRIPPLED_CC */
  651.  
  652. #ifdef CRIPPLED_CC
  653. double str_gnum();
  654. #else /* !CRIPPLED_CC */
  655. #ifdef TAINT
  656. #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
  657.     (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
  658. #else /* !TAINT */
  659. #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
  660. #endif /* TAINT*/
  661. #endif /* CRIPPLED_CC */
  662. EXT STR *Str;
  663.  
  664. #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
  665.  
  666. #ifndef DOSISH
  667. #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
  668. #define Str_Grow str_grow
  669. #else
  670. /* extra parentheses intentionally NOT placed around "len"! */
  671. #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
  672.         str_grow(str,(unsigned long)len)
  673. #define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
  674. #endif /* DOSISH */
  675.  
  676. #ifndef BYTEORDER
  677. #define BYTEORDER 0x1234
  678. #endif
  679.  
  680. #if defined(htonl) && !defined(HAS_HTONL)
  681. #define HAS_HTONL
  682. #endif
  683. #if defined(htons) && !defined(HAS_HTONS)
  684. #define HAS_HTONS
  685. #endif
  686. #if defined(ntohl) && !defined(HAS_NTOHL)
  687. #define HAS_NTOHL
  688. #endif
  689. #if defined(ntohs) && !defined(HAS_NTOHS)
  690. #define HAS_NTOHS
  691. #endif
  692. #ifndef HAS_HTONL
  693. #if (BYTEORDER & 0xffff) != 0x4321
  694. #define HAS_HTONS
  695. #define HAS_HTONL
  696. #define HAS_NTOHS
  697. #define HAS_NTOHL
  698. #define MYSWAP
  699. #define htons my_swap
  700. #define htonl my_htonl
  701. #define ntohs my_swap
  702. #define ntohl my_ntohl
  703. #endif
  704. #else
  705. #if (BYTEORDER & 0xffff) == 0x4321
  706. #undef HAS_HTONS
  707. #undef HAS_HTONL
  708. #undef HAS_NTOHS
  709. #undef HAS_NTOHL
  710. #endif
  711. #endif
  712.  
  713. /*
  714.  * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
  715.  * -DWS
  716.  */
  717. #if BYTEORDER != 0x1234
  718. # define HAS_VTOHL
  719. # define HAS_VTOHS
  720. # define HAS_HTOVL
  721. # define HAS_HTOVS
  722. # if BYTEORDER == 0x4321
  723. #  define vtohl(x)    ((((x)&0xFF)<<24)    \
  724.             +(((x)>>24)&0xFF)    \
  725.             +(((x)&0x0000FF00)<<8)    \
  726.             +(((x)&0x00FF0000)>>8)    )
  727. #  define vtohs(x)    ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
  728. #  define htovl(x)    vtohl(x)
  729. #  define htovs(x)    vtohs(x)
  730. # endif
  731.     /* otherwise default to functions in util.c */
  732. #endif
  733.  
  734. #ifdef CASTNEGFLOAT
  735. #define U_S(what) ((unsigned short)(what))
  736. #define U_I(what) ((unsigned int)(what))
  737. #define U_L(what) ((unsigned long)(what))
  738. #else
  739. unsigned long castulong();
  740. #define U_S(what) ((unsigned int)castulong(what))
  741. #define U_I(what) ((unsigned int)castulong(what))
  742. #define U_L(what) (castulong(what))
  743. #endif
  744.  
  745. CMD *add_label();
  746. CMD *block_head();
  747. CMD *append_line();
  748. CMD *make_acmd();
  749. CMD *make_ccmd();
  750. CMD *make_icmd();
  751. #ifdef macintosh
  752. #define invert    PERL_INVERT
  753. #endif
  754. CMD *invert();
  755. CMD *addcond();
  756. CMD *addloop();
  757. CMD *wopt();
  758. CMD *over();
  759.  
  760. STAB *stabent();
  761. STAB *genstab();
  762.  
  763. ARG *stab2arg();
  764. ARG *op_new();
  765. ARG *make_op();
  766. ARG *make_match();
  767. ARG *make_split();
  768. ARG *rcatmaybe();
  769. ARG *listish();
  770. ARG *maybelistish();
  771. ARG *localize();
  772. ARG *fixeval();
  773. ARG *jmaybe();
  774. ARG *l();
  775. ARG *fixl();
  776. ARG *mod_match();
  777. ARG *make_list();
  778. ARG *cmd_to_arg();
  779. ARG *addflags();
  780. ARG *hide_ary();
  781. ARG *cval_to_arg();
  782.  
  783. STR *str_new();
  784. STR *stab_str();
  785.  
  786. int apply();
  787. int do_each();
  788. int do_subr();
  789. int do_match();
  790. int do_unpack();
  791. int eval();        /* this evaluates expressions */
  792. int do_eval();        /* this evaluates eval operator */
  793. int do_assign();
  794.  
  795. SUBR *make_sub();
  796.  
  797. FCMD *load_format();
  798.  
  799. char *scanpat();
  800. char *scansubst();
  801. char *scantrans();
  802. char *scanstr();
  803. char *scanident();
  804. char *str_append_till();
  805. char *str_gets();
  806. char *str_grow();
  807.  
  808. bool do_open();
  809. bool do_close();
  810. bool do_print();
  811. bool do_aprint();
  812. bool do_exec();
  813. bool do_aexec();
  814.  
  815. int do_subst();
  816. int cando();
  817. int ingroup();
  818. int whichsig();
  819. int userinit();
  820. #ifdef CRYPTSCRIPT
  821. void cryptswitch();
  822. #endif
  823.  
  824. void str_replace();
  825. void str_inc();
  826. void str_dec();
  827. void str_free();
  828. void cmd_free();
  829. void arg_free();
  830. void spat_free();
  831. void regfree();
  832. void stab_clear();
  833. void do_chop();
  834. void do_vop();
  835. void do_write();
  836. void do_join();
  837. void do_sprintf();
  838. void do_accept();
  839. void do_pipe();
  840. void do_vecset();
  841. void do_unshift();
  842. void do_execfree();
  843. void magicalize();
  844. void magicname();
  845. void savelist();
  846. void saveitem();
  847. void saveint();
  848. void savelong();
  849. void savesptr();
  850. void savehptr();
  851. void restorelist();
  852. void repeatcpy();
  853. void make_form();
  854. void dehoist();
  855. void format();
  856. void my_unexec();
  857. void fatal();
  858. void warn();
  859. #ifdef DEBUGGING
  860. void dump_all();
  861. void dump_cmd();
  862. void dump_arg();
  863. void dump_flags();
  864. void dump_stab();
  865. void dump_spat();
  866. #endif
  867. #ifdef MSTATS
  868. void mstats();
  869. #endif
  870.  
  871. HASH *savehash();
  872. ARRAY *saveary();
  873.  
  874. EXT char **origargv;
  875. EXT int origargc;
  876. EXT char **origenviron;
  877. extern char **environ;
  878.  
  879. EXT long subline INIT(0);
  880. EXT STR *subname INIT(Nullstr);
  881. EXT int arybase INIT(0);
  882.  
  883. struct outrec {
  884.     long    o_lines;
  885.     char    *o_str;
  886.     int        o_len;
  887. };
  888.  
  889. EXT struct outrec outrec;
  890. EXT struct outrec toprec;
  891.  
  892. EXT STAB *stdinstab INIT(Nullstab);
  893. EXT STAB *last_in_stab INIT(Nullstab);
  894. EXT STAB *defstab INIT(Nullstab);
  895. EXT STAB *argvstab INIT(Nullstab);
  896. EXT STAB *envstab INIT(Nullstab);
  897. EXT STAB *sigstab INIT(Nullstab);
  898. EXT STAB *defoutstab INIT(Nullstab);
  899. EXT STAB *curoutstab INIT(Nullstab);
  900. EXT STAB *argvoutstab INIT(Nullstab);
  901. EXT STAB *incstab INIT(Nullstab);
  902. EXT STAB *leftstab INIT(Nullstab);
  903. EXT STAB *amperstab INIT(Nullstab);
  904. EXT STAB *rightstab INIT(Nullstab);
  905. EXT STAB *DBstab INIT(Nullstab);
  906. EXT STAB *DBline INIT(Nullstab);
  907. EXT STAB *DBsub INIT(Nullstab);
  908.  
  909. #ifdef macintosh
  910. EXT STAB *aestab INIT(Nullstab);
  911. #endif
  912.  
  913. EXT HASH *defstash;        /* main symbol table */
  914. EXT HASH *curstash;        /* symbol table for current package */
  915. EXT HASH *debstash;        /* symbol table for perldb package */
  916.  
  917. EXT STR *curstname;        /* name of current package */
  918.  
  919. EXT STR *freestrroot INIT(Nullstr);
  920. EXT STR *lastretstr INIT(Nullstr);
  921. EXT STR *DBsingle INIT(Nullstr);
  922. EXT STR *DBtrace INIT(Nullstr);
  923. EXT STR *DBsignal INIT(Nullstr);
  924. EXT STR *formfeed INIT(Nullstr);
  925.  
  926. EXT int lastspbase;
  927. EXT int lastsize;
  928.  
  929. EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
  930. EXT char *origfilename;
  931. EXT FILE * VOLATILE rsfp INIT(Nullfp);
  932. EXT char buf[1024];
  933. EXT char *bufptr;
  934. EXT char *oldbufptr;
  935. EXT char *oldoldbufptr;
  936. EXT char *bufend;
  937.  
  938. EXT STR *linestr INIT(Nullstr);
  939.  
  940. EXT char *rs INIT("\n");
  941. EXT int rschar INIT('\n');    /* final char of rs, or 0777 if none */
  942. EXT int rslen INIT(1);
  943. EXT bool rspara INIT(FALSE);
  944. EXT char *ofs INIT(Nullch);
  945. EXT int ofslen INIT(0);
  946. EXT char *ors INIT(Nullch);
  947. EXT int orslen INIT(0);
  948. EXT char *ofmt INIT(Nullch);
  949. EXT char *inplace INIT(Nullch);
  950. EXT char *nointrp INIT("");
  951.  
  952. EXT bool preprocess INIT(FALSE);
  953. EXT bool minus_n INIT(FALSE);
  954. EXT bool minus_p INIT(FALSE);
  955. EXT bool minus_l INIT(FALSE);
  956. EXT bool minus_a INIT(FALSE);
  957. EXT bool doswitches INIT(FALSE);
  958. EXT bool dowarn INIT(FALSE);
  959. EXT bool doextract INIT(FALSE);
  960. EXT bool allstabs INIT(FALSE);    /* init all customary symbols in symbol table?*/
  961. EXT bool sawampersand INIT(FALSE);    /* must save all match strings */
  962. EXT bool sawstudy INIT(FALSE);        /* do fbminstr on all strings */
  963. EXT bool sawi INIT(FALSE);        /* study must assume case insensitive */
  964. EXT bool sawvec INIT(FALSE);
  965. EXT bool localizing INIT(FALSE);    /* are we processing a local() list? */
  966.  
  967. #ifndef MAXSYSFD
  968. #   define MAXSYSFD 2
  969. #endif
  970. EXT int maxsysfd INIT(MAXSYSFD);    /* top fd to pass to subprocesses */
  971.  
  972. #ifdef CSH
  973. EXT char *cshname INIT(CSH);
  974. EXT int cshlen INIT(0);
  975. #endif /* CSH */
  976.  
  977. #ifdef TAINT
  978. EXT bool tainted INIT(FALSE);        /* using variables controlled by $< */
  979. EXT bool taintanyway INIT(FALSE);    /* force taint checks when !set?id */
  980. #endif
  981.  
  982. EXT bool nomemok INIT(FALSE);        /* let malloc context handle nomem */
  983.  
  984. #ifndef NIXUNIX
  985. #define TMPPATH "/tmp/perl-eXXXXXX"
  986. #else
  987. #define TMPPATH "plXXXXXX"
  988. #endif /* MSMAC */
  989. EXT char *e_tmpname;
  990. EXT FILE *e_fp INIT(Nullfp);
  991.  
  992. EXT char tokenbuf[256];
  993. EXT int expectterm INIT(TRUE);        /* how to interpret ambiguous tokens */
  994. EXT VOLATILE int in_eval INIT(FALSE);    /* trap fatal errors? */
  995. EXT int multiline INIT(0);        /* $*--do strings hold >1 line? */
  996. EXT int forkprocess;            /* so do_open |- can return proc# */
  997. EXT int do_undump INIT(0);        /* -u or dump seen? */
  998. EXT int error_count INIT(0);        /* how many errors so far, max 10 */
  999. EXT int multi_start INIT(0);        /* 1st line of multi-line string */
  1000. EXT int multi_end INIT(0);        /* last line of multi-line string */
  1001. EXT int multi_open INIT(0);        /* delimiter of said string */
  1002. EXT int multi_close INIT(0);        /* delimiter of said string */
  1003.  
  1004. FILE *popen();
  1005. /* char *str_get(); */
  1006. STR *interp();
  1007. void free_arg();
  1008. STIO *stio_new();
  1009. void hoistmust();
  1010. void scanconst();
  1011.  
  1012. EXT struct stat statbuf;
  1013. EXT struct stat statcache;
  1014. EXT STAB *statstab INIT(Nullstab);
  1015. EXT STR *statname INIT(Nullstr);
  1016. #ifndef MSDOS
  1017. #ifdef macintosh
  1018. struct tms {
  1019.     clock_t tms_utime;    /* User CPU time */
  1020.     clock_t tms_stime;    /* System CPU time */
  1021.     clock_t tms_cutime;    /* User CPU time of terminated child procs */
  1022.     clock_t tms_cstime;    /* System CPU time of terminated child procs */
  1023. };
  1024.  
  1025. void    mac_times(struct tms *);
  1026. #define times(x) mac_times(x)
  1027. double mac_atof(const char *);
  1028. #define atof(a)  mac_atof(a)
  1029. #endif
  1030. EXT struct tms timesbuf;
  1031. #endif
  1032. EXT int uid;
  1033. EXT int euid;
  1034. EXT int gid;
  1035. EXT int egid;
  1036. UIDTYPE getuid();
  1037. UIDTYPE geteuid();
  1038. GIDTYPE getgid();
  1039. GIDTYPE getegid();
  1040. EXT int unsafe;
  1041.  
  1042. #ifdef DEBUGGING
  1043. EXT VOLATILE int debug INIT(0);
  1044. EXT int dlevel INIT(0);
  1045. EXT int dlmax INIT(128);
  1046. EXT char *debname;
  1047. EXT char *debdelim;
  1048. #define YYDEBUG 1
  1049. #endif
  1050. EXT int perldb INIT(0);
  1051. #define YYMAXDEPTH 300
  1052.  
  1053. EXT line_t cmdline INIT(NOLINE);
  1054.  
  1055. EXT STR str_undef;
  1056. EXT STR str_no;
  1057. EXT STR str_yes;
  1058.  
  1059. /* runtime control stuff */
  1060.  
  1061. EXT struct loop {
  1062.     char *loop_label;        /* what the loop was called, if anything */
  1063.     int loop_sp;        /* stack pointer to copy stuff down to */
  1064.     jmp_buf loop_env;
  1065. } *loop_stack;
  1066.  
  1067. EXT int loop_ptr INIT(-1);
  1068. EXT int loop_max INIT(128);
  1069.  
  1070. EXT jmp_buf top_env;
  1071.  
  1072. EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
  1073.  
  1074. struct ufuncs {
  1075.     int (*uf_val)();
  1076.     int (*uf_set)();
  1077.     int uf_index;
  1078. };
  1079.  
  1080. EXT ARRAY *stack;        /* THE STACK */
  1081.  
  1082. EXT ARRAY * VOLATILE savestack;        /* to save non-local values on */
  1083.  
  1084. EXT ARRAY *tosave;        /* strings to save on recursive subroutine */
  1085.  
  1086. EXT ARRAY *lineary;        /* lines of script for debugger */
  1087. EXT ARRAY *dbargs;        /* args to call listed by caller function */
  1088.  
  1089. EXT ARRAY *fdpid;        /* keep fd-to-pid mappings for mypopen */
  1090. EXT HASH *pidstatus;        /* keep pid-to-status mappings for waitpid */
  1091.  
  1092. EXT int *di;            /* for tmp use in debuggers */
  1093. EXT char *dc;
  1094. EXT short *ds;
  1095.  
  1096. /* Fix these up for STDMAC */
  1097. #ifdef macintosh
  1098. EXT time_t basetime INIT(0);
  1099. #else
  1100. EXT long basetime INIT(0);
  1101. #endif
  1102. char *mktemp();
  1103. #ifndef STDMAC
  1104. /* All of these are in stdlib.h or time.h for ANSI C */
  1105. double atof();
  1106. long time();
  1107. struct tm *gmtime(), *localtime();
  1108. char *index(), *rindex();
  1109. char *strcpy(), *strcat();
  1110. #endif /* ! STDMAC */
  1111.  
  1112. #ifdef EUNICE
  1113. #define UNLINK unlnk
  1114. int unlnk();
  1115. #else
  1116. #define UNLINK unlink
  1117. #endif
  1118.  
  1119. #ifndef HAS_SETREUID
  1120. #ifdef HAS_SETRESUID
  1121. #define setreuid(r,e) setresuid(r,e,-1)
  1122. #define HAS_SETREUID
  1123. #endif
  1124. #endif
  1125. #ifndef HAS_SETREGID
  1126. #ifdef HAS_SETRESGID
  1127. #define setregid(r,e) setresgid(r,e,-1)
  1128. #define HAS_SETREGID
  1129. #endif
  1130. #endif
  1131.  
  1132. #define SCAN_DEF 0
  1133. #define SCAN_TR 1
  1134. #define SCAN_REPL 2
  1135.